define(function(require,exports,module) {
    var myPub = require('./public');
    // 曝光可视区域元素
    var visualArea = require('./visualAreaInfo');

    var oWindow = $(window);
    var oWrap = $('.js_wrap');
    var oCategorysBox = $('.js_categorysBox');                  // 分类容器
    var oCategorysNavList = $('.js_categorysNavList');          // 导航列表父级
    var oCategoryAllList = $('.js_categorysAllList');
    var oSildeNavJRoll = new myPub.ScrollBar();                 // 导航滚动条
    var oHeader = $('.js_headerBox');                           // 页面头部
    var oFooter = $('.js_footer');                              // 页面底部
    var oContain = $('.js_contain');
    var oTurnLeftGuide = $('.js_turnLeftGuide');                // 页面下部向左滑的引导文字
    var rightOff = $('.js_rightList').hasClass('js_rightActive');// 判断是子分类页还是分类列表页的盒子
    var resizeTimer = null;

    var loadChildCategoryUrl = "/category/loadCategory";
    var loadCategoryGoodsUrl = "/category/loadOne";
    var loadSliderImgUrl = "/category/loadCategoryMaterial";         // 分类轮播图数据
    var perLimit = 20;

    var oCategorysNavControl = $('.js_categorysNavControl');        // 收起和展开
    var sTapOff = true;                                             // 收起展开 开关
    var oTapOff_time = null;                                        // 收起展开 定时器
    var oCategorysNav_time = null;                                  // 导航收起展开 定时器
    var lazLoading = new myPub.lazLoadingImg();

    module.exports = {
        init:function(data,names) {
            cateList.cateInit(true);

            cateList.SetNavList(names);

            // 历史数据初始化
            cateData.HistoryInit();

            // 改变尺寸时更新
            oWindow.resize(function () {
                if(resizeTimer){
                    clearTimeout(resizeTimer);
                }
                resizeTimer = setTimeout(function () {
                    cateList.cateInit(true);
                    cateList.appendSlide();

                    if(!rightOff) {
                        var NavIndex = oCategorysNavList.find('li.active').index();
                        var getGoodsWidth = oCategorysBox.find('.js_categorysDetail').eq(NavIndex).find('li figure').eq(0).parents('a').width();
                        myPub.SetImgHeight(oCategorysBox, getGoodsWidth);
                    }

                },400);
            });

            // 页面跳转记录数据
            oWindow.unload(function () {
                cateData.SetSession();
            });
        }
    };

    // 点击导航展示对应容器
    oCategoryAllList.hammer().on('tap', function (e) {
        var tar = e.gesture.target;
        var $target = $(tar);
        var slideNum,slideNetNum;

        if(tar.tagName.toLowerCase() == 'li') {
            if($target.hasClass('categoryLeftNav')) {
                var index = $target.index();

                //记住最新点击的左侧导航索引
                cateData.catePageNum = index;
                //当点击导航时初始化slider滑动索引
                cateData.cateSlideNum = 0;

                oCategorysNavList.find('li').removeClass('active');
                $target.addClass('active');
                oCategorysBox.find('.js_categorysDetail').hide().eq(index).show();

                if (cateList.loadOff[index]) {
                    cateList.updateShowCon(cateData.catePageNum, cateData.cateSlideNum, cateData.arrNum);
                }
                // 点击侧边导航时让页面下部的“向左滑会有更多精彩哦~”在空数据或者最后一页不显示
                if(!rightOff){
                    slideNum = sessionStorage.getItem('cateSlideNum');
                }else{
                    slideNum = sessionStorage.getItem('cateDetSlideNum');
                }

                if(slideNum && cateData.arrNum[index] == (slideNum*1+1)){
                    oTurnLeftGuide.hide();
                }else if(cateData.arrNum[index] <= 1){
                    oTurnLeftGuide.hide();
                }else if(cateData.arrNum[index] == undefined){
                    oTurnLeftGuide.hide();
                }else{
                    oTurnLeftGuide.show();
                }
            }
        }

        var rightGoodsNav = $target.parents('.jsCategoryRightNav');
        if(rightGoodsNav.length > 0){
            var curIndex = rightGoodsNav.find('.jsHrefCategory').attr('data-curIdx');
            if(curIndex == null){
                curIndex = 0;
            }
            sessionStorage.setItem("cateDetPageNum", curIndex);
            sessionStorage.setItem("cateDetSlideNum", 0);
        }
    });

    // 显示和隐藏导航
    oCategorysNavControl.hammer().on('tap', function (e) {
        var _this = $(this);
        if(sTapOff) {
            sTapOff = false;
            if(_this.hasClass('on')) {
                // 展开
                _this.removeClass('on');
                cateList.NavAnimate(true);
                cateList.NavHideTimer();
            }
            else {
                // 收起
                _this.addClass('on');
                cateList.NavAnimate(false);
            }
            clearTimeout(oTapOff_time);
            oTapOff_time = setTimeout(function () {
                sTapOff = true;
            }, 1200)
        }

        myPub.HamstopPropaga();
    });

    var sliderData = {
        swiperImgData:[],           // 有轮播图数据的分类
        swiperImg:[],               // 轮播图的集合
        swiperImgUrl:[],            // 轮播图的跳转链接
        setSwiperTime:'',           // 轮播图动起来的定时器
        getSliderData:function (index,groupId,fn) {
            var _this = this;
            _this.swiperImg=[];
            _this.swiperImgUrl=[];
            G_JSON_GET(loadSliderImgUrl,{
                groupId:groupId
            },function (data) {
                if(data && data != null && data != undefined && data.length >0){
                    for(var i = 0;i < data.length ;i++){
                        var imageUrl = data[i].imageUrl;
                        if(imageUrl != null && imageUrl != '' && imageUrl != undefined){
                            _this.swiperImg.push(imageUrl);
                            _this.swiperImgUrl.push(data[i].url);
                        }
                    }
                    if(_this.swiperImg.length > 0){
                        _this.swiperImgData[index] = true;
                        if(groupId == -1){      // 如果是推荐页面
                            var oWrapperPage = $('.js_wrapperPage').eq(index);
                            oWrapperPage.find('.js_commend').append(_this.commHtml(_this.swiperImg,_this.swiperImgUrl));

                            oTurnLeftGuide.hide();
                            // 有时候懒加载出不来  就让它滚1像素
                            setTimeout(function () {
                                lazLoading.DestroyLazLoadingImg();
                                lazLoading.AddLazLoadingImg(oWrapperPage.find('.js_commend')[0]);
                                oWrapperPage.find('.js_commend').scrollTop(1);
                            },300)
                        }
                    }
                }
                if(fn)fn();
            }, function () {
                // start
            }, function () {
                // end
            })
        },
        
        // 轮播图拼接
        sliderHtml:function (imgageData,urlData) {
            var _this = this;
            var shtml = "";
            for(var i = 0;i < imgageData.length;i++){
                if(urlData[i] == undefined || urlData[i] == null || urlData[i] == ''){
                    urlData[i] = '#'
                }
                shtml +=
                    ' <div class="swiper-slide">'+
                    '    <a href="'+ urlData[i] + '">'+
                    '      <img class="swiper-lazy" data-src="' + HTTP_IMAGE_URL + imgageData[i] +'"  src="' + BASE_URL + '/static_v4/image/loadImg.jpg" alt="" >'+
                    '    </a>'+
                    ' </div>'
            }

            var slideHtml =
                '<section class="cateListSwiper">'+
                '   <div class="swiper-container js_silderImg js_viewImgBox">'+
                '       <div class="swiper-wrapper">'+
                            shtml+
                '       </div>'+
                '       <div class="swiper-pagination js_pagin"></div>'+
                '   </div>'+
                '</section>';

            return slideHtml
        },

        // 广告轮播图轮播
        swiperAds:function (objArea,objPagin) {
            var indexSwiperAD = [];
            objArea.each(function (i) {
                if(indexSwiperAD[i] == undefined || indexSwiperAD[i] === '') {
                    if(objArea.eq(i).find('.swiper-slide').length < 2){
                        indexSwiperAD = objArea.eq(i).swiper({
                            pagination: objPagin.eq(i),
                            loop: false,
                            autoplay: 2000,
                            autoplayDisableOnInteraction : false,
                            lazyLoading : true
                        });
                        // 去掉轮播图下边的点
                        objPagin.removeClass('swiper-pagination-bullets')
                    }else {
                        indexSwiperAD = objArea.eq(i).swiper({
                            pagination: objPagin.eq(i),
                            loop: true,
                            autoplay: 2000,
                            autoplayDisableOnInteraction : false,
                            lazyLoading : true
                        });
                    }
                }
                else {
                    indexSwiperAD[i].onResize()
                }
            })
        },
        
        // 推荐图片展示代码拼接
        commHtml:function (imgageData,urlData) {
            var _this = this;
            var shtml = "";
            for(var i = 0;i < imgageData.length;i++){
                if(urlData[i] == undefined || urlData[i] == null || urlData[i] == ''){
                    urlData[i] = '#'
                }
                shtml +=
                    ' <a href="'+urlData[i]+'">'+
                    '    <div class="commImg">'+
                    '      <img class="js_lazyImg" data-echo="' + HTTP_IMAGE_URL + imgageData[i] +'"  src="' + BASE_URL + '/static_v4/image/loadImg.jpg" alt="" >'+
                    '    </div>'+
                    ' </a>'
            }
            var slideHtml =
                    '<section class="commTructImg">'+
                        shtml+
                    '</section>';


            return slideHtml;
        },

        // 可以请求轮播图的情况
        askForDataLimit:function (index,materialId,isSplit,fn) {
            var _this = this;
            if(isSplit){
                if(materialId !=  null && materialId != '' && materialId != undefined){
                    _this.getSliderData(index,materialId);          // 请求分类页面轮播图
                    if(fn)fn();
                }
            }else{
                var oWrapperPage = $('.js_wrapperPage').eq(index);
                if(_this.swiperImg.length > 0){
                    if(materialId != -1){
                        oWrapperPage.find('.js_cateSliderImg').eq(0).append(_this.sliderHtml(_this.swiperImg,_this.swiperImgUrl));
                        clearTimeout(_this.setSwiperTime);
                        _this.setSwiperTime = setTimeout(function () {
                            var oSwiperArea = oWrapperPage.find('.js_silderImg');   //广告轮播框
                            var oSwiperPagin = oWrapperPage.find('.js_pagin');      //个数点
                            _this.swiperAds(oSwiperArea,oSwiperPagin);
                        }, 300);
                    }
                }
            }

        }
    };
    var cateData = {
        allCateData:null,           // 记录请求回来的数据
        totalSwiperNum: [],        // 总滑动的页数
        startNum: [],              // 每个小类的开始加载数
        endNum: [],                //  每个小类的结束加载数
        limitNum: 12,               // 每次加载的个数
        pageArr: [],               // 页数
        catePageNum: 0,             // 最新的左侧滚动索引
        cateSlideNum: 0,            // 最新的swiper所滑动到的索引
        arrNum:[],                  // 每个slider的页码数
        getDataList: function (index,categorySign,categoryId, fn) {
            var _this = this;
            var url = "";
            var queryData = {};

            if(!rightOff){
                url = loadChildCategoryUrl;
                queryData = {parentSign:categorySign};
            }else{
                url = loadCategoryGoodsUrl;
                queryData = {categoryId:categoryId,start:0,limit:200};
            }
            G_JSON_POST(url,queryData,function (data) {
                var noDataOff = true;
                if(data != null && data.length > 0){
                    var dataLength = data.length;
                    var oWrapperPage = $('.js_wrapperPage').eq(index);

                    //获取总页数
                    //子分类页显示12个，分类列表页显示4个 当分类有轮播图时第一页显示9个
                    if(!rightOff){
                        if(sliderData.swiperImgData[index]){
                            if(dataLength > 9){
                                _this.limitNum = 12;
                                _this.totalSwiperNum[index] = Math.ceil((parseInt(dataLength)-9) / _this.limitNum) + 1;
                            }else{
                                _this.totalSwiperNum[index] = 1;
                            }

                        }else{
                            _this.limitNum = 12;
                            _this.totalSwiperNum[index] = Math.ceil(parseInt(dataLength) / _this.limitNum);
                        }

                    }else {
                        _this.limitNum = 5;
                        _this.totalSwiperNum[index] = Math.ceil(parseInt(dataLength) / _this.limitNum);
                    }
                    // 点击侧边导航加载数据时让页面下部的“向左滑会有更多精彩哦~”在空数据或者最后一页不显示
                    var navNum = $('.js_categorysNavList li').length;
                    for(var i = 0;i < navNum;i++){
                        _this.arrNum[i] = _this.totalSwiperNum[i];
                    }
                    if(_this.totalSwiperNum[index] <= 1){
                        oTurnLeftGuide.hide()
                    }else{
                        oTurnLeftGuide.show()
                    }
                    // 加载多少个slide
                    cateList.appendWrapperNum(index, _this.totalSwiperNum[index]);

                    // 要添加的内容
                    var cateSlidePage = oWrapperPage.find('.js_slidePageScroll');
                    cateList.appendCategoryGoods( data, _this.totalSwiperNum[index], index, cateSlidePage,rightOff,categorySign);
                    cateList.appendSlide();

                    if(!rightOff) {
                        myPub.SetImgHeight(oWrapperPage);
                    }
                }
                else {
                    oTurnLeftGuide.hide();
                    noDataOff = false;
                    _this.totalSwiperNum[index] = 1;
                    cateList.appendWrapperNum(index, _this.totalSwiperNum[index]);
                }
                if(fn)fn(noDataOff)
            }, function () {
                // start
            }, function () {
                // end
            });
        },
        // 历史数据定位
        HistoryInit : function (fn1, fn2) {
            var _this = this;
            _this.GetSessionData();

            cateList.updateShowCon(_this.catePageNum,_this.cateSlideNum,_this.arrNum);

            if(fn2) fn2();

        },

        // 设置历史定位
        SetSession: function () {
            var _this = this;
            if(!rightOff){
                sessionStorage.setItem("catePageNum", _this.catePageNum);
                sessionStorage.setItem("cateSlideNum", _this.cateSlideNum);
                sessionStorage.setItem("arrNum", _this.arrNum);
            }else {
                sessionStorage.setItem("cateDetPageNum", _this.catePageNum);
                sessionStorage.setItem("cateDetSlideNum", _this.cateSlideNum);
                sessionStorage.setItem("arrNetNum", _this.arrNum);
            }

        },
        // 记录数据历史数据
        GetSessionData: function() {
            var _this = this;
            var catePageNum = 0, cateSlideNum = 0 , arrNum = [] , indexNum;
            if(!rightOff){
                if(sessionStorage.getItem("catePageNum") != null) {
                    catePageNum = sessionStorage.getItem("catePageNum");
                    cateSlideNum = sessionStorage.getItem("cateSlideNum");
                    arrNum = sessionStorage.getItem("arrNum");
                }
            }else {
                if(sessionStorage.getItem("cateDetPageNum") != null) {
                    catePageNum = sessionStorage.getItem("cateDetPageNum");
                    cateSlideNum = sessionStorage.getItem("cateDetSlideNum");
                    arrNum = sessionStorage.getItem("arrNetNum");
                }
            }
            _this.catePageNum = parseInt(catePageNum);
            //设置页面的数据
            _this.cateSlideNum = parseInt(cateSlideNum);
            if(arrNum && arrNum.length > 0){
                indexNum = arrNum.split(',');
            }else{
                return
            }
            _this.arrNum = indexNum;
        }
    }

    var cateList = {
        oSlideGoodsBox:[],
        loadOff: [],            // 加载开关
        navListNames: [],       // 导航数据
        // 初始化
        cateInit:function (bOff) {
            if (bOff) {
                oContain.css({
                    'padding-top': oHeader.outerHeight(true),
                    'padding-bottom': oFooter.outerHeight(true),
                });
                lazLoading.AddLazLoadingImg(oWrap[0]);
                if(oSildeNavJRoll.obj === undefined) {
                    return;
                }
                else {
                    oSildeNavJRoll.ReScroll();
                }
            }
        },

        // 更新记录时调用
        updateShowCon:function (navLiNum, conNum, arr) {
            var $this = this;
            var activeLi = $('.js_categorysNavList').find('li');
            var _navDis = activeLi.eq(navLiNum).position().top;
            activeLi.removeClass('active').eq(navLiNum).addClass('active');
            //显示对应的导航
            var categorySign = activeLi.eq(navLiNum).attr("data-categorySign");
            var categoryId = activeLi.eq(navLiNum).attr("data-categoryId");
            var materialId = activeLi.eq(navLiNum).attr("data-materialId");
            oSildeNavJRoll.ScrollTo(0, -_navDis);

            sliderData.askForDataLimit(navLiNum, materialId, true, function () {
                cateList.loadOff[navLiNum] = false;
            });

            setTimeout(function () {
                var _oCategorysDetail = oCategorysBox.find('.js_categorysDetail')
                //显示对应的内容
                _oCategorysDetail.hide().eq(navLiNum).show();
                cateData.getDataList(navLiNum, categorySign, categoryId, function (bOff) {
                    // 有数据才执行
                    if(bOff) {
                        $this.oSlideGoodsBox[navLiNum].slideTo(conNum, 300 , true);

                        // if(conNum == 0) {
                        //     // 数据统计
                        //     ddjAction.viewGoods(_oCategorysDetail.eq(navLiNum).find('.js_goodsList').eq(conNum), navLiNum);
                        // }
                        // 有本地存储时让页面下部的“向左滑会有更多精彩哦~”在空数据或者最后一页不显示
                        if(arr[navLiNum] == (conNum+1)){
                            oTurnLeftGuide.hide();
                        }else{
                            oTurnLeftGuide.show();
                        }
                    }else{
                        oTurnLeftGuide.hide();
                    }
                    cateList.loadOff[navLiNum] = false;

                    // 4秒后 导航收起
                    cateList.NavHideTimer();

                    if(sliderData.swiperImgData[navLiNum]){
                        // 请求分类页面轮播图
                        sliderData.askForDataLimit(navLiNum, materialId, false);
                    }
                });
            },300);

        },

        // 把请求回来的数据给每个slider加上内容
        appendCategoryGoods : function (data, allNum, index, slideObj,rightOff,categorySign, fn) {
            var $this = this;
            for(var i=0; i<allNum; i++){
                if(cateData.pageArr[index] >= cateData.totalSwiperNum[index]+1) {
                    return;
                }else {
                    cateData.startNum[index] = cateData.endNum[index];
                    if(sliderData.swiperImgData[index]){
                        if( i == 0){
                            cateData.endNum[index] =  cateData.pageArr[index] * 9;
                        }else{
                            cateData.endNum[index] =  cateData.pageArr[index] * cateData.limitNum;
                        }
                    }else{
                        cateData.endNum[index] =  cateData.pageArr[index] * cateData.limitNum;
                    }
                    if(cateData.endNum[index] > data.length){
                        cateData.endNum[index] = data.length;
                    }
                    if(!rightOff){
                        slideObj.eq(i).append($this.leftLoadingHtmlUl(data, cateData.startNum[index], cateData.endNum[index], categorySign));
                    }else {
                        slideObj.eq(i).append($this.leftLoadingHtmlGoods(data, cateData.startNum[index], cateData.endNum[index], categorySign));

                    }
                    cateData.pageArr[index]++;
                    if(fn)fn();
                }
            }
        },
        // 设置导航
        SetNavList: function () {
            var _this = this;
            var _list = oCategorysNavList.find('ul').find('li');
            var length = _list.length;
            var isCommend = _list.eq(0).hasClass('js_careCommend');
            var shtmlBox = "";
            var shtmlCommend = "";
            for (var i=0; i < length; i++) {
                _this.navListNames.push( _list.eq(i).text() );
                cateData.startNum.push(0);
                cateData.endNum.push(0);
                cateData.pageArr.push(1);
                _this.loadOff.push(true);
                if(i == 0 && isCommend){
                    shtmlCommend = '<div class="js_commend commend"></div>'
                }else{
                    shtmlCommend = ''
                }
                shtmlBox +=
                    '<div class="categorysDetail js_categorysDetail" style="display: none;">' +
                    '   <div class="swiper-container js_swiperContainer">' +
                    '       <div class="swiper-wrapper js_wrapperPage">'+ shtmlCommend +'</div>' +
                    '   </div>' +
                    '</div>';
            }


            // 设置产品容器
            oCategorysBox.append(shtmlBox);
            // 导航加滚动
            oSildeNavJRoll.AddScroll(oCategorysNavList[0]);

            // 导航操作时 清除4秒收起的定时器
            oSildeNavJRoll.ScrollStart(function () {
                _this.NavShowTimer();
            });

            oSildeNavJRoll.ScrollEnd(function () {
                _this.NavHideTimer();
            });
        },

        // 加入 swiper-slide
        appendWrapperNum : function (index,appendNum) {
            var shtml = '';
            var $sWraper = $('.js_wrapperPage').eq(index);

            for(var i=0;i<appendNum;i++){
                shtml += '<div class="swiper-slide js_slidePageScroll"></div>'
            }
            $sWraper.append(shtml);
        },

        // 调用swiper
        appendSlide:function () {
            var oGoodsBox = oCategorysBox.find('.js_swiperContainer');
            var $this =this;

            //循环绑定swiper
            oGoodsBox.each(function (i) {
                if($this.oSlideGoodsBox[i] === undefined){
                    $this.oSlideGoodsBox[i]=oGoodsBox.eq(i).swiper({
                        pagination: null,
                        lazyLoading : true,
                        lazyLoadingInPrevNextAmount: 1,
                        touchAngle: 20,
                        keyboardControl: true,
                        touchControl: true,
                        onInit: function (swiper) {
                            // var index = swiper.activeIndex;
                            /*oGoodsBox.eq(i).find('.js_slidePageScroll .js_goods_showOne').hide().eq(0).show();*/
                            // 数据统计
                        },
                        onSlideChangeEnd: function (swiper) {
                            var index = swiper.activeIndex;
                            // 隐藏除当前外的slider
                            oGoodsBox.eq(i).find('.js_slidePageScroll .js_goods_showOne').hide().eq(index).show();
                            // 同步滑动的slider
                            cateData.cateSlideNum = index;
                            cateList.NavHideTimer();
                            cateData.SetSession();
                            // 数据统计
                            // ddjAction.viewGoods(oGoodsBox.eq(i).find('.js_goodsList').eq(index), i);

                            if(cateData.arrNum[i] > 1){
                                if(cateData.arrNum[i] == (index+1)){
                                    oTurnLeftGuide.hide()
                                }else{
                                    oTurnLeftGuide.show()

                                }
                            }
                        },

                    })
                }else {
                    $this.oSlideGoodsBox[i].onResize();
                }

                // 设置app产品跳转链接
                // myPub.JudgeAppHref(oGoodsBox.find('.js_appHref'));
            })

        },

        // 每个当前页面的内容
        leftLoadingHtmlUl:function (data, startNum, endNum, categorySign) {
            var shtmlBox = '';
            var shtml = '';
            for(var i = startNum; i<endNum;i++){
                var dataItem = data[i];
                shtml +=
                    '<li class="js_eachProLi jsCategoryRightNav">'+
                    '    <a class="js_appHref jsHrefCategory" data-curIdx="' + i + '" href="' + BASE_URL + '/category/categoryGoods?parentSign=' + categorySign + '" data-growing-title="'+dataItem.name+'">'+
                    '        <figure>'+
                    '            <img class="swiper-lazy"  data-src="' + HTTP_IMAGE_URL + dataItem.categoryImgPath + smallImgArg200 +'"  src="' + BASE_URL + '/static_v4/image/loadImg.jpg" alt=""  data-growing-title="'+dataItem.name+'">'+
                    '        </figure>'+
                    '        <aside class="priceArea">'+
                    '            <div class="priceArea_name">'+
                    '                <h4>' + dataItem.name + '</h4>'+
                    '            </div>'+
                    '        </aside>'+
                    '    </a>'+
                    '</li>';
            }
            shtmlBox =
                '<div class="categorysGoods js_categorysGoods">'+
                '    <div class="categorysGoods goodsList ListgoodsList ">'+
                '        <div class="js_cateSliderImg"></div>'+
                '        <ul class="clearfix">'+
                            shtml+
                '        </ul>'+
                '    </div>'+
                '</div>';
            return shtmlBox;
        },

        leftLoadingHtmlGoods:function (data,startNum,endNum) {
            var shtml = '';
            for(var i = startNum; i<endNum;i++){
                var dataItem = data[i];

                //全额保障  选择性显示哪些右上角图标
                var html_firstGueeImagePath = '';
                var firstGueeImagePath=dataItem.firstGueeImagePath;
                if(firstGueeImagePath!=null && firstGueeImagePath!=""){
                    var gueeUrl = firstGueeImagePath;
                    html_firstGueeImagePath = '<div class="quanpei"><img src="'+ gueeUrl +'" alt="" /></div>';
                }

                var html_goodsLabels = '';
                if(dataItem.goodsLabels && dataItem.goodsLabels != ""){
                    html_goodsLabels = '<i class="promotionHotIcon">'+ dataItem.goodsLabel +'</i>';
                }

                var html_isTuangou = '';
                if(dataItem.isTuangou){
                    html_isTuangou =
                        '<span class="goodsPrice">￥' + dataItem.tuangouPrices + '</span>'+
                        '<span class="tuangouNum">/<span>￥' + dataItem.salePrice + '</span></span>'
                }else{
                    html_isTuangou = '<span class="goodsPrice">￥' + dataItem.salePrice + '</span>'
                }

                var html_label = '';
                if(dataItem.label && dataItem.label != ''){
                    html_label += '<p class="promotionSale">';
                    for(var j=0;j<dataItem.labels.length;j++){
                        html_label += '<i>'+dataItem.labels[j]+'</i>'
                    }
                    html_label += '</p>';
                }


                shtml +=
                    '<li>'+
                    '   <a class="BoxSelf" href="' + BASE_URL + '/h/goodspay/goodsView/' + dataItem.goodsSn + '" data-growing-title="'+dataItem.name+'" goodsid="'+ data[i].id +'" >'+
                    '       <figure>'+
                    '           <img class="swiper-lazy" data-src="' + HTTP_IMAGE_URL + dataItem.showImage + smallImgArg200 +'" src="' + BASE_URL + '/static_v4/image/loadImg.jpg"  data-growing-title="'+dataItem.name+'"/>' +
                                html_firstGueeImagePath +
                    '       </figure>'+
                    '      <aside class="priceArea VBox Bflex1">'+
                    '           <div class="Bflex1 priceArea_name">'+
                    '               <h4>' +  html_goodsLabels + dataItem.name + '</h4>'+
                    '               <p class="smallFont_tip">' + dataItem.title + '</p>'+
                    '           </div>'+
                    '           <div class="priceArea_price">'+
                    // '               <i class="tip-info">买一送一</i>'+
                    '               <p class="HBox priceAreaBox">' +
                                        html_isTuangou +
                     // '                  <span class="goodsSpecNum">/' + dataItem.productName + '</span>'+
                    '               </p>'+
                    '           </div>'+
                    '       </aside>'+
                    '   </a>' +
                    '   <p class="addCar js_addCar" pid="' + dataItem.productId + '"><em class="icon-shopcar_small"></em></p>'+
                            html_label +
                    //'   <p class="promotionSale horpromotionSale"><i>限时立减150</i><i>第二件半价</i></p>'+
                    '</li>';



            }

            var shtmlBox =
                '<div class="categorysListGoods">'+
                '    <div class="goods_showChangeBox js_goods_showOne ">'+
                '        <div class="goods_showChange">'+
                '            <ul class="goodsList clearfix js_goodsList">'+
                                shtml+
                '           </ul>'+
                '       </div>'+
                '   </div>'+
                '</div>';
            return shtmlBox;
        },

        // 导航展开和收缩
        NavAnimate: function (off) {
            if(off) {
                // 展开
                oCategorysNavList.stop().animate({
                    'left': 0
                },300);

                oCategorysBox.stop().animate({
                    'margin-left': '6.9rem'
                },300, function () {
                    cateList.appendSlide();
                });
            }
            else {
                // 收起
                oCategorysNavList.stop().animate({
                    'left': '-6.9rem'
                },300);

                oCategorysBox.stop().animate({
                    'margin-left': 0
                },300, function () {
                    cateList.appendSlide();
                });
            }
        },

        // 导航添加4秒倒计时隐藏
        NavHideTimer : function () {
            // 检测有收起按钮时 才加定时器
            if(oCategorysNavControl.length > 0  && !oCategorysNavControl.hasClass('on')) {
                clearTimeout(oCategorysNav_time);
                oCategorysNav_time = setTimeout(function () {
                    oCategorysNavControl.addClass('on');
                    cateList.NavAnimate(false);
                }, 4000);
            }
        },

        // 导航显示
        NavShowTimer : function () {
            clearTimeout(oCategorysNav_time);
            oCategorysNavControl.removeClass('on');
        }

    }

    // 用户行为
    var ddjAction = {
        viewData: [],
        viewGoods: function (obj, iNow) {
            // 首页和分类区分
            var ddjActionPositionId = {};

            ddjActionPositionId.positionId = 2;
            ddjActionPositionId.positionFirst = '分类';
            ddjActionPositionId.positionSecond = cateList.navListNames[iNow];

            // 统计曝光数据
            visualArea.viewEl.showViewEls( obj, function (data, dataJson) {
                ddjhoc.setData(data, 'rec_show', 'add', function () {
                    console.log('ddjhoc.params.rec_show.cate', ddjhoc.params);
                    if( ddjhoc.params.length != 0 ) ddjhoc.sendData( ddjhoc.params );

                    console.log('ddjhoc.ddjParams.rec_show.cate', ddjhoc.ddjParams);
                    if( ddjhoc.ddjParams.length != 0 ) ddjhoc.sendDDJData( ddjhoc.ddjParams );

                }, dataJson, ddjActionPositionId);
            });
        }
    }

});